/*
 * lcd_169_cst816.c
 *
 *  Created on: Mar 25, 2025
 *      Author: QkLia
 */

#include "lcd_169_cst816s.h"
#include "i2c.h"

#define TP_IIC_HANDLE &hi2c1

void tp_write_byte(uint16_t reg, uint8_t dat){
	HAL_I2C_Mem_Write(TP_IIC_HANDLE, 0x15<<1, reg, I2C_MEMADD_SIZE_8BIT, &dat, 1, 1);
}

void tp_read_nbyte(uint16_t reg, uint8_t* dat, uint16_t size){
	if((*TP_IIC_HANDLE).State == HAL_I2C_STATE_READY)
	HAL_I2C_Mem_Read(TP_IIC_HANDLE, (0x15<<1)+1, reg, I2C_MEMADD_SIZE_8BIT, dat, size, size);
}

void tp_init(){

	TP_RES_START
	HAL_Delay(10);
	TP_RES_STOP
	HAL_Delay(100);

	tp_write_byte(0xED, 1); //设置中断低脉冲宽度，单位1ms

	tp_write_byte(0xFE, 1); //关闭自动进入低功耗模式

}
